#include"SplitToolJieba.h"
#include<iostream>

using std::string;
using std::vector;
using std::cout;


     SplitTool::~SplitTool()
     {}

     SplitToolJieba::~SplitToolJieba()
     {
        cout<<" ~ start \n";
        if(_jieba)
        {
        delete _jieba;
        _jieba=nullptr;
        }
        if(_hasher)
        {
        delete _hasher;
        _hasher=nullptr;
        }
     }
//构造配置文件路径
SplitToolJieba::SplitToolJieba(Configuration * conf)
    :_conf(conf)
{
    map<string ,string> config=_conf->GetConfigMap();
    const char* const _dict = config["DICT_PATH"].c_str();
    const char* const _hmm=config["HMM_PATH"].c_str();
    const char* const _user_dict=config["USER_DICT_PATH"].c_str();
    const char* const _idf=config["IDF_PATH"].c_str();
    const char* const _stop=config["STOP_WORD_PATH"].c_str();
     _jieba = new cppjieba::Jieba(_dict,_hmm,_user_dict,_idf,_stop);
     _hasher = new Simhasher(_dict,_hmm,_idf,_stop);
}

     Simhasher* SplitToolJieba::hasher() 
{
    return _hasher;
}
//中文分词
     std::vector<std::string> SplitToolJieba::cut(const std::string& sentence) 
{
    vector<string> words;

    _jieba->Cut(sentence,words);

    return words;
}






